﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.OleDb;
using System.Data;
using DTO;

namespace DAO
{
    public class SachDAO : AbstractDAO
    {
        public List<SachDTO> GetAll()
        {
            OleDbConnection connection = Open();
            string sql = "SELECT * FROM Sach";
            OleDbCommand command = new OleDbCommand(sql, connection);
            OleDbDataReader reader = command.ExecuteReader();
            List<SachDTO> dsSach = new List<SachDTO>();
            SachDTO s;
            while (reader.Read())
            {
                s = new SachDTO();
                s.MaSach = reader.GetInt32(0);
                s.TenSach = reader.GetString(1);
                s.TacGia = reader.GetString(2);
                s.MaTheLoai = reader.GetInt32(3);
                s.SoLuongTon = reader.GetInt32(4);
                s.DonGiaNhap = reader.GetDouble(5);
                s.TinhTrang = reader.GetBoolean(6);
                dsSach.Add(s);
            }
            Close(connection);
            return dsSach;
        }
    }
}



